<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pnCommerceCheckoutHeader.php,v $
 * $Author: landseer $
 * $Revision: 1.4 $
 * $Date: 2004/04/28 12:43:23 $
 *
 * Type: Function
 *
 * Purpose:  prepares the checkout header and returns it
 */
function smarty_function_pnCommerceCheckoutHeader($params, &$smarty)
{
    $actStep = pnSessionGetVar( 'PNCActStep' );
    $maxStep = pnSessionGetVar( 'PNCMaxStep' );

    pnModLoad('pncommerce','user');
    pnModAPILoad('pncommerce','user');
    
    $co = array( 
            array( 'num' => 0, 'desc' => ''                  , 'link' => '' ),
            array( 'num' => 1, 'desc' => _PNC_ADDRESSSTEP        , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'userinfo' ) ),
            array( 'num' => 2, 'desc' => _PNC_PAYMETHODSTEP      , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'getpaymethod' ) ),
            array( 'num' => 3, 'desc' => _PNC_PAYMETHODDETAILSTEP, 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processpaymethod' ) ),
            array( 'num' => 4, 'desc' => _PNC_SHIPPINGSTEP       , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'getshippingmethod' ) ),
            array( 'num' => 5, 'desc' => _PNC_SHIPPINGDETAILSTEP , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processshippingmethod' ) ),
            array( 'num' => 6, 'desc' => _PNC_SHOWSUMMARYSTEP    , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'checkout' ) ),
            array( 'num' => 7, 'desc' => _PNC_PAYMETHODFINALSTEP , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processpaymethod' ) ),
            array( 'num' => 8, 'desc' => _PNC_SHIPPINGFINALSTEP  , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processshippingmethod' ) ),
            array( 'num' => 9, 'desc' => _PNC_SHOWRECEIPTSTEP    , 'link' => '' ) );

	$temp = "<table width='100%' border='1'><tr>\n";
//    show all available links to the recent steps
	foreach( $co as $step )
	{
	    if( $step['num'] < $actStep )
	    {
	        // link
		    $temp .= "<td align='center'><i><a href=\"".$step['link']."\">".$step['desc']."</a> <i></td>\n";
	    }
	    elseif( $step['num'] == $actstep )
	    {
	        // no link, italic
		    $temp .= "<td align='center'>".$step['desc']."</td>\n";
	    }
	    else
	    {
	        // normal text
    		$temp .= "<td align='center'>".$step['desc']."</td>\n";
	    }
    }
	    
	$temp .= "</tr></table>";

// debug info	
	$temp .= "<br>PNCActStep :$actStep: PNCMaxStep :$maxStep: PNCUser :".pnSessionGetVar('PNCUser').":";
    return $temp;

}
?>
